use "dataset_east_baton_rouge_cross", clear

local i = 1

foreach y in logncrimeincidentspcp logbuildingpermitspcp logpropertyvalues {
	
	if "`y'" == "logncrimeincidentspcp" local ytitle "Crime"
	if "`y'" == "logbuildingpermitspcp" local ytitle "Building permits"
	if "`y'" == "logpropertyvalues" local ytitle "Property values"

	foreach x in pctnhblack distancemi {

		if "`x'" == "pctnhblack" local xtitle "Share Black"
		if "`x'" == "distancemi" local xtitle "Distance from shooting"
	
		cor `y' `x' [aw=totalvotes]
		local myrho = string(`r(rho)', "%20.02fc")
	
		#delimit;
		
		gr tw
			(sc `y' `x', col(gray) msym(O) msize(small))
			(lpoly `y' `x' [aw=totalvotes], col(black) lwid(thick))
			,
				legend(off)
				plotregion(style(none))
				ylab(, angle(horiz))
				name(g`i', replace)
				xtitle(`xtitle')
				ytitle(`ytitle')
				subtitle("r=`myrho'")
				;
				
		#delimit cr
		
		gr close
		
		local i = `i' + 1
	
	}
	
}

gr combine g1 g2 g3 g4 g5 g6, rows(3) ysize(5) xsize(4)

gr export "_output/figure A9.pdf", replace
